﻿const router = require('koa-router')()
const activityModle=require('../models/activity')
const {updata,updata1,areaData}=require('../config/updata')



router.prefix('/api')


//    创建活跃度表
router.post('/createHuoyuedu',async(ctx)=>{

    let data=ctx.request.body
    let res=await activityModle.create(data)
    ctx.body={

        code:200,
        msg:"创建成功"
    }
})

// 省活跃度统计页面
//    获取全部省活跃度
router.get("/getActivityData",async(ctx)=>{

    let resoult=await activityModle.find({})
    ctx.body={
        code:200,
        res: updata(resoult)
    }


})

// 查询省活跃度
router.post('/queryActivityData',async(ctx)=>{
    let data=ctx.request.body
    console.log(data);
    let resoult=await activityModle.find(data)
    console.log(resoult);
    ctx.body={
        code:200,
        resoult:updata(resoult)
    }

})

//获取全部市活跃度
router.get('/getCityactivity',async(ctx)=>{
    let resolut=await  activityModle.find({})
    ctx.body={
        code:200,
        resolut:updata1(resolut)
    }

})

//查询市活跃度
router.post('/queryCityactivity',async(ctx)=>{
    let data=ctx.request.body
    console.log(data);
    let resoult=await activityModle.find(data)
    console.log(resoult);
    ctx.body={
        code:200,
        resoult:updata1(resoult)
    }

})

//获取区活跃度
router.get("/getAreaactivity",async(ctx)=>{
    let resoult=await activityModle.find({})

    ctx.body={
        code:200,
        resoult:areaData(resoult)
    }

})

//查询区活跃度
router.post('/queryAreaactivity',async(ctx)=>{
    let data=ctx.request.body
    console.log(data);
    let resoult=await activityModle.find(data)
    console.log(resoult);
    ctx.body={
        code:200,
        resoult:areaData(resoult)
    }

})




module.exports = router
